package com.bjpowernode.mvc.controller;


import cn.hutool.core.bean.BeanUtil;
import com.bjpowernode.db.result.IncomeProductResult;
import com.bjpowernode.mvc.model.response.Response;
import com.bjpowernode.mvc.model.vo.income.IncomeProductResultVO;
import com.bjpowernode.mvc.service.inter.IncomeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class IncomeController {

    @Resource
    private IncomeService incomeService;
    //查询收益记录.

    @GetMapping(value = "/income/more")
    public Response queryMore(@RequestHeader("uid") Integer userId,Integer pageNo,Integer pageSize){

        pageNo=(pageNo == null || pageNo<1)?1:pageNo;
        pageSize=(pageSize == null || pageSize<1)?6:pageSize;

       List<IncomeProductResult> incomeProductResults= incomeService.queryMoreByUid(userId,pageNo,pageSize);

       //转vo
        List<IncomeProductResultVO> incomeVOlist = BeanUtil.copyToList(incomeProductResults, IncomeProductResultVO.class);


        //返回结果.
        return Response.ok(incomeVOlist);
    }
}
